<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>我的购物车</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    	function deleteItem(id){
    	var  b = window.confirm("确定要删除吗？");
           if(b){
				window.location.href="${pageContext.request.contextPath}/user!delete.action?method=remove&cid="+id;           
           }
    	}
         function changequantity(input,id,oldvalue){
           //得到修改的数量
          var quantity = input.value;
          
          //判断是否是正整数
          if(quantity<0 || quantity!=parseInt(quantity)){
                 alert("请输入合理的数值");
                 input.value=oldvalue;
                 return;
          }
           var  b = window.confirm("是否将数量修改为："+quantity);
           if(b){
				window.location.href="${pageContext.request.contextPath}/user!delete.action?method=change&cid="+id+"&count="+quantity;           
           }
       
       }
    
    </script>
</head>
<body>
	<div class="page">
		<div class="welcome wuser2">
			欢迎来到
			<点卡销售网>用户中心！ 
		</div>
		<table width="200" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td><div class="cm">订单编号</div>
				</td>
				<td><div class="cm">商品名称</div>
				</td>
				<td><div class="cs">价格</div>
				</td>
				<td><div class="cs">数量</div>
				</td>
				<td><div class="cs">小计</div>
				</td>
				<td><div class="cs">操作</div>
				</td>
			</tr>
			<c:if test="${listcart!= null}">
				<c:forEach var="card" items="${listcart}" varStatus="cardtype">
					<tr>
						<td>${card.cardtype.id}</td>
						<td>${card.cardtype.cardTypeName}</td>
						<td><span style="color:red;">${card.cardtype.cardPrice}</span>元</td>
						<td><input type="text" value="${card.count}" id="num"
							name="num" size="4"
							onchange="changequantity(this,${card.cardtype.id},${card.count})" />
						</td>
						<td><span style="color:red;">${card.count*card.cardtype.cardPrice}</span>元</td>
						<td><a href="javascript:deleteItem(${card.cardtype.id})">删除</a>
						</td>
					</tr>
				</c:forEach>
			</c:if>
			<c:if test="${listcart==null}">
				<tr>
					<td colspan="6" align="center" style="color:red;">购物车没有任何商品！</td>
				</tr>
			</c:if>
			<tr>
				<td colspan="2" class="lastRow">商品总金额：<span style="color:red;">${talprice}</span>元</td>
				<td colspan="2" class="lastRow"><a
					href="${pageContext.request.contextPath}/index!shows.action"
					target="_blank"><input type="button" value="" class="continue" />
				</a></td>
				<td colspan="2" class="lastRow"><a
					href="${pageContext.request.contextPath}/shopping!Balance.action"
					target="_blank"><input type="button" value="" class="checkout" />
				</a></td>
			</tr>
		</table>

	</div>
</body>
</html>
